{% extends 'base_jgdw.html' %}
{% load staticfiles %}
{% block title %}
    <title>河南省农业行政执法机构队伍管理平台-{{ request.user }}</title>
{% endblock %}
{% block css %}
    <style>
        td, th {
            text-align: center
        }

        .mytd1 {
            min-width: 90px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .mytd2 {
            min-width: 70px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .mytd3 {
            max-width: 220px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .mytd4 {
            max-width: 100px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .fooNone, .foo {
            background-color: #ffd2d2
        }
    </style>
{% endblock %}

{% block body %}
    <div class="container" style="padding: 0px">
        <hr>
        <div class="panel panel-info">
            <div class="panel-heading">
                <h3 class="panel-title">
                    执法人员列表
                </h3>
            </div>
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th> 省辖市</th>
                            <th> 县市区</th>
                            <th> 姓名</th>
                            <th> 手机号码</th>
                            <th> 单位名称</th>
                            <th> 学历</th>
                            <th> 编制</th>
                            <th> 转业军人</th>
                            <th> 审核状态</th>
                            <th> 操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% for foo in list %}
                            <tr class="foo{{ foo.level }}">
                                <td>
                                    <div class="">{{ foo.organization.xingzhengquhua.shi }}</div>
                                </td>
                                <td>
                                    <div class="">{{ foo.organization.xingzhengquhua.xian }}</div>
                                </td>
                                <td>
                                    <div class="">{{ foo.name }}</div>
                                </td>
                                <td>
                                    <div class="">{{ foo.phone }}</div>
                                </td>
                                <td>
                                    <div class="">{{ foo.organization.title }}</div>
                                </td>
                                <td>
                                    <div class="">{% if foo.xueli %}
                                        {{ foo.get_xueli_display }}
                                    {% endif %}</div>
                                </td>
                                <td>
                                    <div class="">{% if bzlx.xueli %}
                                        {{ foo.get_bzlx_display }}
                                    {% endif %}</div>
                                </td>
                                <td>
                                    <div class="">{{ foo.get_junren_display }}</div>
                                </td>
                                <td>
                                    <div class="">
                                        {% if foo.level %}
                                            已审核
                                        {% else %}
                                            未审核
                                        {% endif %}
                                    </div>
                                </td>
                                <td>
                                    <a class="btn btn-danger btn-sm notok" id="{{ foo.id }}" role="button">不通过</a>
                                    <a class="btn btn-success btn-sm ok" id="{{ foo.id }}" role="button">通过</a>
                                </td>
                            </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                    <ul class="pagination pagination-sm pull-right">
                        {{ page_obj.page_str|safe }}
                    </ul>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block js %}
    <script>
        $('.pagination ').append('<li><a href="/download/ry/"><span class="glyphicon glyphicon-download-alt"></span></a></li>')
        $(".ok").click(function () {
            id = $(this).attr("id")
            td = $(this).parents('tr').children('td').eq(8)
            tr = $(this).parents('tr.foo')
            console.log(tr)
            $.ajax({
                url: "/zfry_shtg/" + id + "/",
                type: "get",
                dataType: "json",
                success: function (arg) {
                    if (arg.status == 200) {
                        td.text('已审核')
                        tr.removeClass('foo')
                    } else if (arg.status == 400) {
                        swal('出错了', '您的权限不足，审核失败！', 'warning')
                    }
                }
            })
        })
        $(".notok").click(function () {
            id = $(this).attr("id")
            td = $(this).parents('tr').children('td').eq(8)
            tr = $(this).parents('tr')
            $.ajax({
                url: "/zfry_shbtg/" + id + "/",
                type: "get",
                dataType: "json",
                success: function (arg) {
                    if (arg.status == 200) {
                        td.text('未审核')
                        tr.addClass('foo')
                    } else if (arg.status == 400) {
                        swal('出错了', '您的权限不足，审核失败！', 'warning')
                    }
                }
            })
        })
    </script>
{% endblock %}



